home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Utilities / MandelNet / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-14  |  2.8 KB  |  175 lines  |  [TEXT/KAHL]

  1. #include "mandel.h"
  2.  
  3.  
  4. RestartProc()
  5. {
  6.     ExitToShell();
  7. }
  8.  
  9.  
  10.  
  11. main()
  12. {
  13. EventRecord        theEvent;
  14. WindowPtr        whichWindow;
  15. char            theChar;
  16.  
  17.     InitGraf(&thePort);
  18.     InitFonts();
  19.     FlushEvents( everyEvent, 0 );
  20.     InitWindows();
  21.     InitMenus();
  22.     TEInit();
  23.     InitDialogs(RestartProc);
  24.     InitCursor();
  25.     MaxApplZone();
  26.     
  27.     receiveRecord = (ABRecHandle) NewHandle(atpSize);
  28.     
  29.     if (receiveRecord == 0L)
  30.         FatalError("\p Can't allocate memory for receiveRecord");
  31.     
  32.     nbpRegistered = FALSE;
  33.     nbpName = 0L;
  34.     
  35.     if (OptionKey())
  36.     {
  37.         ErrorAlert("\p Master mode enabled");
  38.         slaveMode = FALSE;
  39.     }
  40.     else
  41.         slaveMode = TRUE;
  42.     
  43.     shading = TRUE;
  44.     numSlaves = 0;
  45.     coords = FALSE;
  46.     meToo = TRUE;
  47.     timeDelay = 3.0;
  48.     
  49.     theDisplayMessages[0][0] = 0;
  50.     theDisplayMessages[1][0] = 0;
  51.     theDisplayMessages[2][0] = 0;
  52.     
  53.     lims[xmin] = -2.0;
  54.     lims[xmax] = 1.0;
  55.     lims[ymin] = -1.5;
  56.     lims[ymax] = 1.5;
  57.     
  58.     maxIterations = 10;
  59.     pixelSize = 1;
  60.     
  61.     SetUpCursors();
  62.     SetUpMenus();
  63.     
  64.     InitWindow();
  65.     
  66.     if (SetupAppleTalk() != noErr)
  67.         FatalError("\p Can't set up AppleTalk!");
  68.     
  69.     DrawInfo();
  70.     
  71.     FlushEvents(everyEvent,0);
  72.     
  73.     AwaitRequest(receiveRecord,&theMessage);
  74.     
  75.     alive = TRUE;
  76.  
  77.     while (alive)
  78.     {
  79.         SystemTask();
  80.         MaintainMenus();
  81.         MaintainCursor();
  82.         
  83.         if (GetNextEvent(everyEvent,&theEvent))
  84.         {
  85.             switch (theEvent.what)
  86.             {
  87.                 case networkEvt:
  88.                     if (slaveMode==TRUE && theEvent.message==(long) receiveRecord)
  89.                     {
  90.                         if (RespondToRequest(receiveRecord) == noErr)
  91.                             AwaitRequest(receiveRecord,&theMessage);
  92.                     }
  93.                     
  94.                     break;
  95.                 
  96.                 case mouseDown:
  97.                     switch (FindWindow(theEvent.where,&whichWindow)) 
  98.                     {
  99.                         case inMenuBar:
  100.                             DoCommand(MenuSelect(theEvent.where));
  101.                             break;
  102.                             
  103.                         case inSysWindow:
  104.                             SystemClick(&theEvent,whichWindow);
  105.                             break;
  106.                             
  107.                         case inContent:
  108.                             if (whichWindow != FrontWindow())
  109.                                 SelectWindow(whichWindow);
  110.                             
  111.                             else if (whichWindow == theWPtr)
  112.                                 DoContent(&theEvent);
  113.                             
  114.                             break;
  115.                         
  116.                         case inDrag:
  117.                             if (whichWindow != FrontWindow())
  118.                                 SelectWindow(whichWindow);
  119.                             
  120.                             else if (whichWindow == theWPtr)
  121.                                 DoDrag(whichWindow,&theEvent);
  122.                             
  123.                             break;
  124.                     }
  125.                     
  126.                     break;
  127.                 
  128.             case keyDown:
  129.             case autoKey: 
  130.                 
  131.                 theChar = theEvent.message & charCodeMask;
  132.                     
  133.                 if (theEvent.modifiers & cmdKey)
  134.                     DoCommand(MenuKey(theChar));
  135.                 
  136.                 else
  137.                     SysBeep(1);
  138.                 
  139.                 break;
  140.                 
  141.             case activateEvt:
  142.                 if ((WindowPtr) theEvent.message == theWPtr) 
  143.                 {
  144.                     if (theEvent.modifiers & activeFlag) 
  145.                     {
  146.                         
  147.                     }
  148.                     else 
  149.                     {
  150.                         
  151.                     }
  152.                 }
  153.                 
  154.                 break;
  155.                 
  156.             case updateEvt: 
  157.                 if ((WindowPtr) theEvent.message == theWPtr) 
  158.                 {
  159.                     UpdateWindow();
  160.                 }
  161.                 
  162.                 break;
  163.             }
  164.         }
  165.     }
  166.     
  167.     
  168. ExitPoint:
  169.     ShutDownAppleTalk();
  170.     
  171.     DisposHandle(receiveRecord);
  172.     DisposPtr(graphBits.baseAddr);
  173.     
  174.     return(0);
  175. }